<!DOCTYPE html >
<html xmlns="http://www.w3.org/1999/xhtml" dir="ltr" lang="zh-CN">
<head >
    <title></title>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
    <style>
        body {  font-size:12px;}
        table{border:0px;  margin:5px auto; font-size:12px;}
        .histogram{ height:20px; background:green; margin:0px;}
        .pager_container{ width: 90%; }
        .pager_container div{width: 30px; height: 30px; border:1px solid #fdfdfd; float:left; margin-left: 10px;color:black; text-align: center; border: 1px solid #cccccc;}
        .pager_container a{text-decoration: none;  display: block; font-size: 12px; color: #4997da; margin-top: 7px;}
        .pager_container a:hover{ background:#cccccc; color:white;}
        .pager_current{ background:#cccccc; color:white;width: 30px; height: 30px; font-weight: bold; }
        .categoryTable{ background: #f1f8ff;border: 2px #86c3f7 solid;}
        .categoryTable td{ height: 30px; border-bottom: 1px #cccccc dotted; padding-left: 5px;}
        .fristCate{
            font-size: 12px; font-weight: bold; color: #4997da;text-decoration: none;
        }
        .fristCate:hover{
            text-decoration: underline;
        }
        .notFristCate{
            font-size: 10px;  color: #4997da;text-decoration: none;

        }
        .appTable td{
            border-bottom: 1px #cccccc dotted; padding-left: 5px; padding-top: 3px; padding-bottom: 0px;
            padding-left: 10px; padding-right: 10px;
        }
        .appTable .tbHead{
            background: #eee;
            line-height: 20px;
            vertical-align: middle;
            border-bottom: 1px solid #000;
        }
        .appTitle{
            font-size: 14px;  color: #4997da;text-decoration: none;

        }
        .appTable td p{
            color: #666666; line-height: 16px;

        }
        .appTable td span{
            color: gray; line-height: 16px; float: right;

        }
        #btnAllService{
            display: block;
            width: 100px;
            height: 20px;
            text-align: center; 
            background: #86c3f7;
            font-size: 14px;
            text-decoration: none;
            color: white;
            font-weight: bold;

        }
        #btnAllService:hover{
            color:black;

        }
        .redTd{
            background: red;
            font-weight:bold;
            
        }
        .redTd a{
            color: white;
            
        }
    </style>

</head>
<body>
<table width="1000px" >
    <tr>

        <td > 
            <?php

                function getCateById($id){
                    $c = new Model_Category();
                    $c -> loadById($id);
                    return $c->category.'(id:'.$id.')';
                }
            ?>
            首页<?php while($cate = array_pop($cateTree)){echo ' >> '.getCateById($cate);}?>
        </td>
        <td>
            当前分类供有 <?php echo $totalNums?>个服务
        </td>

    </tr>
</table>
<table width="1000px"   cellspacing=1 cellpadding=1 >
    <tr>
        <td width="20%" valign="top">  
            <table border="0px"  width="90%" align="left" class="categoryTable" cellpadding="0" cellspacing="0">
                <tr>
                    <td style="font-size: 14px; font-weight: bold; color: #fff; background-color: #86c3f7; border: 0;">
                        <a href="<?php echo U('index','index',array('all'=>'0'));?>">
                            全部卖家服务<?php echo AUtil::getCountById(1);?>
                        </a>
                    </td>
                </tr>
                <?php
                    function print_tree($root){
                        static $deep = 0;
                        $deep ++;
                        $local_deep = $deep;
                        foreach($root as $id => $item){
                            echo '<tr>
                            <td>';
                            for($i = $local_deep; $i> 0; $i--){echo '&nbsp;&nbsp;';}
                            echo '<a href="'.U('index','index',array('cid'=>$id)).'"';
                            if($local_deep == 1)echo ' class ="fristCate" ';
                            if($local_deep != 1)echo ' class ="notFristCate" ';
                            echo '>'.$item['cate_name'].AUtil::getCountById($id).'</a>
                            </td>
                            </tr>';
                            if(is_array($item['sub_tree'])){
                                print_tree($item['sub_tree']);
                            }
                        }
                    }

                    print_tree($tree);
                ?>

            </table>
        </td>
        <td valign="top" width="100%">
            <table class="appTable" border="0" align="left" width="100%">
                <tr class="tbHead">
                    <td width="60">图标</td>
                    <td width="270px">名字(供应商为空的均为淘宝官方)</td>
                    <td  width="40" <?php echo $_GET['order'] == 'free_trial'?'class="redTd"':'';?>>
                    <a href="<?php echo U('','',array('order' => 'free_trial','cid'=>$cid))?>">免费用量</a>
                    </td>
                    <td  width="40" <?php echo $_GET['order'] == 'pay_trial'?'class="redTd"':'';?>>
                    <a href="<?php echo U('','',array('order' => 'pay_trial','cid'=>$cid))?>">付费用量</a>
                    </td>
                    <td width="30" <?php echo $_GET['order'] == 'both_trial'?'class="redTd"':'';?>>
                    <a href="<?php echo U('','',array('order' => 'both_trial','cid'=>$cid))?>">总量</a>
                    </td>
                    <td width="30">浏览量</td>
                </tr>
                <?php
                    while($service = Widget_Db::fetch_object($serviceData)){
                    ?>
                    <tr>
                        <td><img src="<?php echo $service -> img_url?>" width="60" height="60"></td>
                        <td valign="top" width="200px">
                        <a href="<?php echo $service -> url?>" class="appTitle" target="_blank"><?php echo $service -> name?></a> 
                        <a href="<?php echo $service -> vendor_url?>" target='_blank'> <span><?php echo $service -> vendor?></span></a>
                            <p><?php echo $service -> desc?></p>

                        </td>
                        <td><?php echo $service-> free_trial?></td>
                        <td><?php echo $service-> pay_trial?></td>
                        <td><?php echo ($service-> free_trial + $service-> pay_trial)?></td>
                        <td><?php echo $service -> click?></td>
                    </tr>

                    <?php
                }?>

            </table>
            <table  border="0" align="left" width="100%">
                <tr>
                    <td width="60">
                        <?php echo $pagenav?>
                    </td>

                </tr>
            </table>
        </td>
    </tr>

    </table>